05. Exercise: Lifecycle Events

Lifecycle Events

We have two toy apps for this lesson. The first one is a logger to help you understand the activity lifecycle. Open the LogLifecycle exercise using the link below. You're going to follow the TODOs to add code to the MainActivity, and use the logAndAppend functions to log onCreate, onStart, onResume, onPause, onStop, onRestart and onDestroy.

Exercise Code

Exercise: T05a.01-Exercise-LogLifecycle

Now run the app, rotate the device (or emulator), look in the Android Monitor (not in the text view), and answer the following question:

What is the order that the lifecycle events are called after the device is rotated.

SOLUTION: onPause, onStop, onDestroy, onCreate, onStart, onResume